package cn.jiyun.mongodb;

import com.mongodb.BasicDBObject;
import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import org.junit.Test;

/**
 * @author Fay
 * @date 2022/6/29&19:19
 */
public class mongodbDemo4 {
    @Test
    public void delete(){
        //建立连接
        MongoClient client = new MongoClient("127.0.0.1");
        //获取数据库
        MongoDatabase spitdb = client.getDatabase("spitdb");
        //获取集合
        MongoCollection<Document> spit = spitdb.getCollection("spit");

        BasicDBObject basicDBObject = new BasicDBObject("userid","9999");

        spit.deleteOne(basicDBObject);
    }
}
